package hai.JRedisTest;

import org.apache.commons.lang3.StringUtils;

import redis.clients.jedis.Jedis;

public class JedisUtil {

    public static Jedis createJedis() {
        Jedis jedis = new Jedis("127.0.0.1");
        return jedis;
    }

    public static Jedis createJedis(String host, int port) {
        Jedis jedis = new Jedis(host, port);

        return jedis;
    }

    public static Jedis createJedis(String host, int port, String passwrod) {
        Jedis jedis = new Jedis(host, port);

        if (StringUtils.isNotBlank(passwrod)){
            jedis.auth(passwrod);
        }
        
        return jedis;
    }
    
    
    public static void main(String[] args){
    	Jedis jedis = JedisUtil.createJedis("121.199.2.5", 6379, "my_redis");
    	long start = System.currentTimeMillis();
    	for(int i = 0 ; i < 1000 ; i++){
    		System.out.println(jedis.get("foo"));
    	}
    	long end = System.currentTimeMillis();
    	System.out.println("time:" + (end - start)/1000);
    }
    
}